<template>
  <div>
    <Header :left="true" leftText="返回" title="加严填报审核" />
    <div>
      <van-tabs
        v-model="active"
        type="card"
        :offset-top="80"
        :sticky="true"
        @click="tabChange"
        swipeable
        style="top: 8px; font-size: 15px"
        color="#1c6c8d"
      >
        <!-- 未关闭的加严管控 -->
        <van-tab title="未审核" style="font-size: 15px">
          
          <van-row style="margin-top: 20px"> </van-row>
          <div class="textScroll">
            <div
              v-for="(item) in itemsOne"
              :key="item.Id"
              style="position: relative"
            >
              <div style="width: 100%; background-color: #f3f4f8; height: 5px">
                <span></span>
              </div>
              <div class="divStyle">
                
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"><b>生产线:</b></van-col>
                  <van-col span="14">{{ item.PLineID }}</van-col>
                </van-row>

                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"><b>生产订单:</b></van-col>
                  <van-col span="14">{{
                    showPOrderIDName(item.POrderID)
                  }}</van-col>
                </van-row>

                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"><b>加严开始时间:</b></van-col>
                  <van-col span="14">{{ item.FromDatetime }}</van-col>
                </van-row>


                <van-row style="margin-left: 10px; margin-top: 10px;padding-bottom: 15px;">
                  <van-col span="6"><b>加严原因:</b></van-col>
                  <van-col span="14">{{
                    showAddStrictTypeName(item.StrictTypeID)
                  }}</van-col>
                  <van-col span="2" >
                    <van-button
                      color="#138087"
                      @click.stop="toAudit(item.Id)"
                      style="
                        width: 85px;
                        height: 40px;
                        font-size: 12px;
                        position: absolute;
                        left: 80%;
                      "
                      type="primary"
                      text="审核"
                    />
                  </van-col>
                  
                 
                </van-row>

  
                <van-row
                  style="
                    margin-left: 10px;
                    margin-top: 10px;
                    border-bottom: 2px solid rgba(82, 76, 76, 0.39);
                  "
                >
                  <van-col span="6"> </van-col>
                  <van-col span="3"> </van-col>
                  <van-col span="6"> </van-col>
                </van-row>
              </div>
            </div>
          </div>
        </van-tab>
        <!-- 已关闭的加严管控 -->
        <van-tab title="已审核">
          
          <div class="textScroll2">
            <div
              v-for="(item) in itemsTwo"
              :key="item.Id"
              style="position: relative"
            >
              <div style="width: 100%; background-color: #f3f4f8; height: 5px">
                <span></span>
              </div>
              <div class="divStyle">
                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"><b>生产线:</b></van-col>
                  <van-col span="14">{{ item.PLineID }}</van-col>
                </van-row>

                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"><b>生产订单:</b></van-col>
                  <van-col span="14">{{
                    showPOrderIDName(item.POrderID)
                  }}</van-col>
                </van-row>

                <van-row style="margin-left: 10px; margin-top: 10px">
                  <van-col span="6"><b>加严开始时间:</b></van-col>
                  <van-col span="14">{{ item.FromDatetime }}</van-col>
                </van-row>


                <van-row style="margin-left: 10px; margin-top: 10px;padding-bottom: 15px;">
                  <van-col span="6"><b>加严原因:</b></van-col>
                  <van-col span="14">{{
                    showAddStrictTypeName(item.StrictTypeID)
                  }}</van-col>
                  <van-col span="2" >
                    <van-button
                      color="#138087"
                      @click.stop="toAudit(item.Id,true)"
                      style="
                        width: 85px;
                        height: 40px;
                        font-size: 12px;
                        position: absolute;
                        left: 80%;
                      "
                      type="primary"
                      text="查看"
                    />
                  </van-col>
                 
                </van-row>
                <van-row
                  style="
                    margin-left: 10px;
                    margin-top: 10px;
                    border-bottom: 2px solid rgba(82, 76, 76, 0.39);
                  "
                >
                  <van-col span="6"> </van-col>
                  <van-col span="3"> </van-col>
                  <van-col span="6"> </van-col>
                </van-row>
              </div>
            </div>
          </div>
        </van-tab>
      </van-tabs>
    </div>
  </div>
</template>
  
<script>
import {
  Col,
  Row,
  Form,
  Cell,
  Icon,
  Field,
  tab,
  tabs,
  NumberKeyboard,
  Image as VanImage,
  Picker,
  popup,
  SubmitBar,
  Button,
  Loading,
  Overlay,
  Dialog,
  Toast,
  NoticeBar,
  Tag,
  DatetimePicker,
  ImagePreview,
  CellGroup,
  Uploader,
  Cascader,
  Calendar,
  RadioGroup,
  Radio,
  Divider,
  Stepper,
  AddressList,
  Checkbox,
  CheckboxGroup,
} from "vant";

import "vue-easytable/libs/themes-base/index.css";
import { VTable } from "vue-easytable";
import { _httpClient } from "@/libs/apisie";
import { _httpClient as _httpClientApi } from "@/libs/api";
import { _httpClient as _httpClientApisie } from "@/libs/apisie";
import { getToken, getBaseApiFrefix } from "@/libs/auth";
import Header from "@/components/header.vue";
import { storage } from "@/libs/utils";

Vue.use(Form);
Vue.use(Field);
Vue.use(Overlay);
Vue.use(Loading);
Vue.use(Picker);
Vue.use(popup);
Vue.use(SubmitBar);
Vue.use(VanImage);
Vue.use(DatetimePicker);
Vue.use(Cascader);
Vue.use(Calendar);
Vue.use(Cell);
Vue.use(RadioGroup);
Vue.use(Radio);
Vue.use(Divider);
Vue.use(Stepper);
Vue.use(Button);
Vue.use(AddressList);
Vue.use(Checkbox);
Vue.use(CheckboxGroup);
Vue.use(Col);
Vue.use(Row);
Vue.use(tab);
Vue.use(tabs);

export default {
  name: "tightauditList",
  components: {
    Form,
    Row,
    Col,
    Button,
    Header,
    Form,
    Cell,
    Icon,
    Field,
    NumberKeyboard,
    Dialog,
    Toast,
    NoticeBar,
    Row,
    Tag,
    popup,
    DatetimePicker,
    ImagePreview,
    CellGroup,
    Uploader,
    Col,
    Calendar,
    Cascader,
    Picker,
    RadioGroup,
    Radio,
    Divider,
    Stepper,
    VTable,
    AddressList,
    Checkbox,
    CheckboxGroup,
    tab,
    tabs,
  },
  data() {
    return {
      form: [],
      itemsOne: [],
      itemsTwo: [],
      shiftMap:{},
      preCheck:false,
      columnsPOrderID: [],
      columnsABCType: [
        { ABCType: "1", ABCTypeName: "甲" },
        { ABCType: "2", ABCTypeName: "乙" },
        { ABCType: "3", ABCTypeName: "丙" },
        { ABCType: "4", ABCTypeName: "-未确定" },
      ],
      columnsPLineID: [],
      columnsStrictTypeID: [
        { StrictTypeID: "SM01", StrictTypeName: "关键工艺参数异常加严" },
        { StrictTypeID: "SM02", StrictTypeName: "机器设备异常加严" },
        { StrictTypeID: "SM03", StrictTypeName: "质量异常加严" },
        { StrictTypeID: "SM04", StrictTypeName: "生产条件异常加严" },
        
      ],

    };
  },
  filters:{
    fBool(b){
      return b?'是':'否'
    }
  },
  created: function () {
    //获取当前系统登录用户
    this.user = JSON.parse(storage.get("user"));
    this.user.userId = this.user.userName;
    this.getList();

   
    this.getPline();
    this.getPOrderID();

    this.$ac.addEventListener({
        name: 'tightaudit'
    }, (ret, err)=> {
     
      this.getList()
        
    });
    
  },
  mounted() {},

  methods: {

    async getList() {
      let _this = this;
      Toast.loading({
        mask: true,
        forbidClick: true,
        duration: 0,
        message: "Loading...",
      });
      try {
        let res = await _httpClientApisie.get(
          _httpClientApisie.getApiPrefix() +
            "/AddStrictManage/GetList?Processed="+this.preCheck
        );

        Toast.clear();
       
        if(this.preCheck){
          _this.itemsTwo=res.Data
        }else{
          _this.itemsOne = res.Data;
        }


        
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    toAudit(id,lock=false){


      this.$ac.openWin({
        name: "tightaudit",
        url: "./tightenup-tightaudit.html",
        pageParam: {
          id: id,
          lock:lock
        }
      });
      
    },
    tabChange(name, title) {
      this.preCheck=!this.preCheck
      if (!this.preCheck) {
        this.itemsOne = [];
        //查询未审核信息
      } else if (name == 1) {
        //查询已审核信息
        this.itemsTwo = [];
      }
      this.getList()
    },

    showPOrderIDName(POrderID) {
      var POrderIDName = POrderID;
      this.columnsPOrderID.forEach((item) => {
        if (item.POrderID === POrderID) {
          POrderIDName = item.POrderIDAndMaterialName;
        }
      });
      return POrderIDName;
    },
    showABCTypeName(ABCType) {
      var ABCTypeName = ABCType;
      this.columnsABCType.forEach((item) => {
        if (item.ABCType === ABCType) {
          ABCTypeName = item.ABCTypeName;
        }
      });
      return ABCTypeName;
    },
    showPLineIDName(PLineID) {
      var PLineName = PLineID;
      this.columnsPLineID.forEach((item) => {
        if (item.PLineID === PLineID) {
          PLineName = item.PLineName;
        }
      });
      return PLineName;
    },
    showAddStrictTypeName(AddStrictType) {
      var AddStrictTypeName = AddStrictType;
      this.columnsStrictTypeID.forEach((item) => {
        if (item.StrictTypeID === AddStrictType) {
          AddStrictTypeName = item.StrictTypeName;
        }
      });
      return AddStrictTypeName;
    },

    async getPOrderID() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/ProductionOrder/GetList"
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            POrderID: item.POrderID,
            MaterialName: item.MaterialName,
            MaterialID: item.MaterialID,
            POrderIDAndMaterialName: item.POrderID + " " + item.MaterialName,
          }));
          _this.columnsPOrderID = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    },
    async getPline() {
      let _this = this;
      try {
        let res = await _httpClient.get(
          _httpClient.getApiPrefix() + "/PLineEquipment/GetList?FactoryID=TC00"
        );
        if (res.HttpCode === "200") {
          let teamMap = res.Data.map((item) => ({
            PLineID: item.PLineID,
            PLineName: item.PLineName,
          }));
          _this.columnsPLineID = teamMap;
        }
      } catch (e) {
        Toast.fail(JSON.stringify(e));
      }
    }
  },
};
</script>
  
<style>
body {
  background-color: white;
}
.textScroll {
  display: inline-block;
  position: fixed;
  top: 6rem;
  bottom: -10px;
  overflow: scroll;
  right: 0;
  width: 100%;
  margin-bottom: 4.7rem;
  z-index: 1;
}
.textScroll2 {
  display: inline-block;
  position: fixed;
  top: 6rem;
  bottom: -10px;
  overflow: scroll;
  right: 0;
  width: 100%;
  margin-bottom: 4.7rem;
  z-index: 1;
}
</style>
  